/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YCKOKO
 * Date: 2022-10-21
 * Time: 10:17
 */
import java.util.Scanner;
public class Login {
    public String username = "Traceless";
    public String password = "123456";
    public void logininfo(String username,String passworld){
        try{
            if(!this.username.equals(username)){
                throw new PassWordException("用户名错误");
                //System.out.println("用户名错误");
                //return;
            }
            if(!this.password.equals(passworld)){
                throw new PassWordException("密码错误");
                //System.out.println("密码错误");
                //return;
            }
            System.out.println("登录成功！");
        }catch(UserNameExpection e){
            e.printStackTrace();
        }catch(PassWordException e){
            e.printStackTrace();
        }

    }
    //实现一个简单的控制台版用户登陆程序, 程序启动提示用户输入用户名密码. 如果用户名密码出错, 使用自定义异常的方式来处理
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入你的用户名：");
        String  username = scanner.nextLine();
        System.out.print("请输入你的密码：");
        String  passworld = scanner.nextLine();
        Login login = new Login();
        login.logininfo(username,passworld);
    }
}
